﻿using FluentValidation.Results;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RockBus.Routing
{
    public static class FluentValidationExtensions
    {
        public static string ToErrorString(this ValidationResult result)
        {
            if (result == null)
            {
                throw new ArgumentNullException("ValidationResult");
            }

            if (result.IsValid)
            {
                return "ValidationResult: Valid.";
            }

            var sb = new StringBuilder("ValidationResult: Invalid. Errors: ");
            foreach (var error in result.Errors)
            {
                sb.AppendLine(error.ToString());
            }
            return sb.ToString();
        }
    }
}
